home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / DESK / CORE / Desk / h_doc / Font < prev    next >
Text File  |  1996-06-25  |  10KB  |  369 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Font.h
  12.     Author:  Copyright © 1993 Shaun Blackmore, Julian Smith
  13.     Version: 1.02 (08 Jul 1995)
  14.     Purpose: Assembler SWI veneers for the Font Manager
  15.              NOTE that some names are not strictly 'DeskLib' style, to keep
  16.              them consistent with the SWIs they represent ("Converttopoints",
  17.              etc). However, macros with 'DeskLib' naming are provided to allow
  18.              either naming style to be used.
  19.     Mods:    08 Jul 1995 - Julian Smith - Added Desk_Font_Paint3 for use with RISC
  20.                                           OS 3. Also various macros for the
  21.                                           'plottype' argument of Desk_Font_Paint3.
  22. */
  23.  
  24. #ifndef __Desk_Font_h
  25. #define __Desk_Font_h
  26.  
  27. #ifdef __cplusplus
  28.     extern "C" {
  29. #endif
  30.  
  31.  
  32. #ifndef __Desk_Core_h
  33.     #include "Desk.Core.h"
  34. #endif
  35.  
  36. #ifndef __Desk_Wimp_h
  37.     #include "Desk.Wimp.h"
  38. #endif
  39.  
  40.                                    
  41. typedef int Desk_font_handle;
  42.  
  43. typedef struct
  44. {
  45.   char name[128];   /* NOTE: Desk_Font_ReadDefn returns this string CR terminated */
  46.   int xsize, ysize, xres, yres;
  47.   int age, usage;
  48. } Desk_font_defn;
  49.  
  50.  
  51. typedef struct
  52. {
  53.     int minx, miny, maxx, maxy;
  54. } Desk_font_info;
  55. /*
  56. Used with Desk_Font_ReadInfo
  57. */
  58.  
  59. typedef struct
  60. {
  61.   char *s;              /* string */
  62.   int x;                /* in/out, in 1/72000s of an inch */
  63.   int y;                /* in/out, in 1/72000s of an inch */
  64.   int split;            /* in/out: space char, or -1      */
  65.                         /*         on exit, = count of space or printable */
  66.   int term;             /* in/out: index into s */
  67. } Desk_font_string;
  68. /*
  69. Used with Desk_Font_FindCaret, Desk_Font_StringWidth.
  70. */
  71.  
  72. typedef struct
  73. {
  74.   int background, foreground;
  75. } Desk_font_colours;
  76.  
  77.  
  78. typedef struct
  79. {
  80.   Desk_font_handle  font;
  81.   Desk_font_colours colour;
  82.   int          offset;
  83. } Desk_font_state;
  84. /*
  85. Used with Desk_Font_CurrentFont and Desk_Font_FutureFont.
  86. */
  87.  
  88. typedef struct
  89. {
  90.   char offset;
  91.   char thresholds[15];
  92. } Desk_font_thresholds;
  93. /*
  94. Used with Desk_Font_ReadThresholds
  95. */
  96.  
  97.    /*  Font usage array  (Desk_font_array)
  98.     *  This array is indexed by the font handle - each entry contains a
  99.     *  count of how many times we have FindFont'd this font. This is used
  100.     *  mainly by the template system (Desk_Wimp_LoadTemplate).
  101.     *  See Desk_Font_LoseAllFonts
  102.     *  For convenience, this is defined in Wimp.h (it is mainly used for
  103.     *  template loading)
  104.     *
  105.     *  typedef struct
  106.     *  {
  107.     *    char fonts[256];
  108.     *  } Desk_font_array;
  109.     */
  110.  
  111. extern void    Desk_Font_CacheAddr(int *version, int *cacheused, int *cachesize);    /* PRMS 3-418 */
  112. extern void    Desk_Font_ListFonts(char *name, int *count);            /* PRMS 3-450 */
  113.  
  114. extern void    Desk_Font_ReadDefn(Desk_font_handle font, Desk_font_defn *defn);        /* PRMS 3-424 */
  115. extern void    Desk_Font_ReadInfo(Desk_font_handle font, Desk_font_info *info);        /* PRMs 3-426 */
  116.  
  117. extern void    Desk_Font_ConverttoOS(int x, int y, int *xout, int *yout);        /* PRMs 3-438 */
  118. #define Desk_Font_ConvertToOS Desk_Font_ConverttoOS                    /* PRMs 3-438 */
  119. /*
  120. Converts x and y from millipoints to OS coors.
  121. (normally 400millipoints = 1 OS unit).
  122. Both xout and yout must be valid addresses, even if you are only
  123. interested in (say) xout.
  124. */
  125.  
  126. extern void    Desk_Font_Converttopoints(int x, int y, int *xout, int *yout);    /* PRMs 3-439 */
  127. #define Desk_Font_ConvertToPoints Desk_Font_Converttopoints                /* PRMs 3-439 */
  128.  
  129. extern void    Desk_Font_FindFont(Desk_font_handle *font, const char *name,
  130.                                int xsize, int ysize, int xres, int yres);    /* PRMs 3-419 */
  131.  
  132. extern void    Desk_Font_LoseFont(Desk_font_handle font);                /* PRMs 3-423 */
  133.  
  134. extern void Desk_Font_LoseAllFonts(Desk_font_array *fonts);
  135. /*  Desk_Font_LoseAllFonts
  136.  *  Given a font usage array, this function calls Desk_Font_Lose for all fonts
  137.  *  used, and sets the font usage array to zeros. See above for info on
  138.  *  how a font usage array is organised...
  139.  */
  140.  
  141. extern void    Desk_Font_SetFont(Desk_font_handle font);        /* PRMs 3-440 */
  142. extern void    Desk_Font_CurrentFont(Desk_font_state *state);        /* PRMs 3-441 */
  143. extern void    Desk_Font_FutureFont(Desk_font_state *state);        /* PRMs 3-443 */
  144.  
  145. extern void    Desk_Font_Paint(char *, int options, int x, int y);    /* PRMs 3-429 */
  146. /*
  147. Use Desk_Font_Paint3 to use RISC OS 3 features.
  148. */
  149.  
  150. extern void    Desk_Font_Caret(int colour, int height, int flags, int x, int y);    /* PRMs 3-436 */
  151. extern void    Desk_Font_FindCaret(Desk_font_string *string);                /* PRMs 3-444 */
  152. extern void    Desk_Font_FindCaretJ(Desk_font_string *s, int xoffset, int yoffset);    /* PRMs 3-461 */
  153.  
  154. extern void    Desk_Font_StringWidth(Desk_font_string *string);        /* PRMs 3-427 */
  155. extern void    Desk_Font_CharBBox(Desk_font_handle font, char c,
  156.                                int flags, Desk_font_info *info);    /* PRMs 3-446 */
  157. extern void    Desk_Font_StringBBox(char *string, Desk_font_info *info);/* PRMs 3-463 */
  158.  
  159. extern void    Desk_Font_ReadScaleFactor(int *xscale, int *yscale);/* PRMs 3-448 */
  160.  
  161. extern void    Desk_Font_SetFontColours(Desk_font_handle font,
  162.                                      int Desk_back_colour, int Desk_fore_colour,
  163.                                      int offset);
  164. extern void    Desk_Font_SetPalette(int Desk_back_log,  int Desk_fore_log,
  165.                                  int offset,
  166.                                  int Desk_back_phys, int Desk_fore_phys);
  167.  
  168. extern void    Desk_Font_ReadThresholds(Desk_font_thresholds *t);
  169. extern void    Desk_Font_SetThresholds(Desk_font_thresholds *t);
  170.  
  171.  
  172.  
  173.  
  174.  
  175. #define Desk_font_justify_NONE    (0)
  176. /*
  177. No justification
  178. */
  179.  
  180. #define Desk_font_justify_CURSOR    (1<<0)
  181. /* 
  182. Justify between startpos and last graphics position.
  183. Not to be used with Desk_font_justify_COORBLOCK or 
  184. Desk_font_justify_NONE.
  185. */
  186.  
  187. #define Desk_font_justify_COORBLOCK    (1<<5)
  188. /*
  189. Justify according to 8-word coordinate pointed to by r5
  190. Not to be used with Desk_font_justify_CURSOR, 
  191. Desk_font_justify_NONE or Desk_font_plot_OSCOORS.
  192. */
  193.  
  194.  
  195. #define Desk_font_rubout_NONE    (0)
  196. /*
  197. Don't do a rubout.
  198. */
  199.  
  200. #define Desk_font_rubout_CURSOR    (1<<1)
  201. /*
  202. Use the last two graphics cursor positions to define
  203. the rubout box.
  204. */
  205.  
  206. #define Desk_font_rubout_COORBLOCK    (1<<1 + 1<<5)
  207. /*
  208. Rubout box is defined by the Desk_font_coorblock pointed to by r5.
  209. Not RISC OS 2.
  210. Not to be used with Desk_font_plot_OSCOORS.
  211. */
  212.  
  213. #define Desk_font_plot_OSCOORS    (1<<4)
  214. /*
  215. Coors are in OS coors.
  216. Not to be used with Desk_font_justify_COORBLOCK or
  217. Desk_font_rubout_COORBLOCK.
  218. */
  219.  
  220. #define Desk_font_plot_TRANSMATRIX    (1<<6)
  221. /*
  222. Use transformation matrix pointed to by r6
  223. Not RISC OS 2.
  224. Not to be used with Desk_font_plot_OSCOORS.
  225. */
  226.  
  227. #define Desk_font_STRLEN    (1<<7)
  228. /*
  229. r7 is length of string
  230. Not RISC OS 2
  231. */
  232.  
  233. #define Desk_font_plot_CURRENTHANDLE    (1<<8)
  234. /*
  235. Use current handle iff r0=0
  236. Not RISC OS 2
  237. */
  238.  
  239. #define Desk_font_plot_KERN        (1<<9)
  240. /*
  241. Kern the string.
  242. Not RISC OS 2.
  243. */
  244.  
  245.  
  246. typedef struct    {
  247.     struct    {
  248.         Desk_wimp_point    space;
  249.         Desk_wimp_point    letter;
  250.         }
  251.         offsets;
  252.         
  253.     Desk_wimp_rect    rubout;
  254.     }
  255.     Desk_font_coorblock;
  256. /*
  257. Used with Desk_Font_Paint3
  258. */
  259.     
  260.  
  261. typedef struct    {
  262.     struct    {
  263.         int    xx;    /* These names may not be right...    */
  264.         int    xy;
  265.         int    yx;
  266.         int    yy;
  267.         }
  268.         scale;
  269.         
  270.     Desk_wimp_point    translate;
  271.     }
  272.     Desk_font_transformation;
  273. /*
  274. Used with Desk_Font_Paint3
  275. */
  276.  
  277.  
  278.  
  279. void    Desk_Font_Paint3( 
  280.             Desk_font_handle        font, 
  281.             const char        *string, 
  282.             unsigned int        plottype,
  283.             int            x,
  284.             int            y,
  285.             Desk_font_coorblock        *coorblock,
  286.             Desk_font_transformation    *transformation,
  287.             int            length
  288.             );
  289. /*
  290.  
  291. Veneer for the RISC OS 3 Desk_Font_Paint SWI.  Note that Desk_Font_Paint doesn't 
  292. support any of the RISC OS 3 features.
  293.  
  294. See PRM 3-429
  295.  
  296. 'plottype' should be a combination (using '|' rather than '+', because
  297. some bits are set in more than one macro) of Desk_font_justify_NONE,
  298. Desk_font_justify_CURSOR, Desk_font_justify_COORBLOCK, Desk_font_rubout_NONE,
  299. Desk_font_rubout_CURSOR, Desk_font_rubout_COORBLOCK, Desk_font_plot_OSCOORS,
  300. Desk_font_plot_TRANSMATRIX, Desk_font_STRLEN, Desk_font_plot_CURRENTHANDLE,
  301. Desk_font_plot_KERN.
  302.  
  303.  
  304. There are rather complicated rules for which of these are allowed at the
  305. same time. The following is what I think is the situation.
  306.  
  307. You can use:
  308.  
  309. Only one of: Desk_font_justify_NONE, Desk_font_justify_CURSOR,
  310. Desk_font_justify_COORBLOCK
  311.  
  312. Only one of: Desk_font_rubout_NONE, Desk_font_rubout_CURSOR, Desk_font_rubout_COORBLOCK
  313.  
  314. In addition, you may not use Desk_font_plot_OSCOORS  with any of
  315. Desk_font_justify_COORBLOCK, Desk_font_rubout_COORBLOCK, Desk_font_plot_TRANSMATRIX
  316.  
  317.  
  318. Another way of looking at this, is:
  319.  
  320. You can use just one Desk_font_justify_*
  321.  
  322. You can use just one Desk_font_rubout_*
  323.  
  324. You can only use Desk_font_plot_OSCOORS if you don't use any of:
  325. Desk_font_justify_COORBLOCK, Desk_font_rubout_COORBLOCK, Desk_font_plot_TRANSMATRIX
  326.  
  327.  
  328. Note that both Desk_font_justify_COORBLOCK and Desk_font_rubout_COORBLOCK use
  329. Desk_wimp_rect 'coorblock'. If you use either of these, 'coorblock' mustn't
  330. be NULL.
  331.  
  332.  
  333. Just for fun, here's a run-down of the justification and rubout bits  in
  334. Desk_Font_Paint's r2:
  335.  
  336. Bit
  337. 5 0 | Justification
  338. ----+--------------
  339. 0 0 | None
  340. 0 1 | Cursor
  341. 1 0 | Coor block r5
  342. 1 1 | Illegal
  343.  
  344. Bit
  345. 5 1 | Rubout
  346. ----+--------------
  347. 0 0 | None
  348. 0 1 | Cursor
  349. 1 0 | Illegal
  350. 1 1 | Coor block r5
  351.  
  352.  
  353. These are rather unsymetrical...
  354.  
  355. */
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363. #ifdef __cplusplus
  364. }
  365. #endif
  366.  
  367.  
  368. #endif
  369.